package com.nacrtstudio.webgiftshop.core.dao.service.impl;

import org.hibernate.Session;
import org.springframework.transaction.annotation.Transactional;

import com.nacrtstudio.webgiftshop.core.dao.HibernateDao;
import com.nacrtstudio.webgiftshop.core.dao.service.CreateCommand;

public class CreateCommandImpl<Type> implements CreateCommand<Type>{
	private Type object;
	private HibernateDao<Session> hibernateDao;

	public Type getObject() {
		return object;
	}

	public void setObject(Type object) {
		this.object = object;
	}

	public HibernateDao<Session> getHibernateDao() {
		return hibernateDao;
	}

	public void setHibernateDao(HibernateDao<Session> hibernateDao) {
		this.hibernateDao = hibernateDao;
	}

	@Transactional
	public Type execute() {
		getHibernateDao().save(object);
		return (Type) object;
	}

}
